<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
    <title>设置项目启动</title>
    <meta content="webkit" name="renderer"/>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
    <meta
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
            name="viewport"
    />
    <link href="../js/layui/css/layui.css" media="all" rel="stylesheet"/>
    <link href="../style/home.css" media="all" rel="stylesheet"/>
    <script src="../js/layui/layui.js"></script>
</head>
<body>
<div class="layui-panel" style="margin: 32px;">
    <div style="margin: 20px;">
        <form class="layui-form" action="">
            <input type="hidden" name="id" th:value="${id}">
            <div class="layui-form-item">
                <label class="layui-form-label">起动日期</label>
                <div class="layui-input-block">
                    <input type="text" name="sdate" class="layui-input" id="sdate" th:value="${sdate}"
                           placeholder="请选择项目启动日期">
                </div>
            </div>

            <button type="submit" class="layui-btn" lay-submit="" lay-filter="postButton" id="postButton"
                    style="display: none">
                提交
            </button>
        </form>
    </div>
</div>
</body>
<script>
    var callBackReturn = false,
        OnPost = false;
    var index = parent.layer.getFrameIndex(window.name);

    layui.use(function () {
        var laydate = layui.laydate;
        var form = layui.form;
        var $ = layui.$;
        // 渲染
        laydate.render({
            elem: '#sdate'
        });

        form.on('submit(postButton)', function (obj) {
            var data = obj.field;
            $.ajax({
                url: './projectStart',
                dataType: 'json',
                type: 'POST',
                async: false,
                data: JSON.stringify(data),
                contentType: "Application/json",
                success: function (result) {
                    if (result.code == 0 || result.code == 200) {
                        parent.layer.msg(result.message, {icon: 1});
                        callBackReturn = true;
                        OnPost = true;
                        parent.layer.close(index);
                    } else {
                        OnPost = true;
                        parent.layer.alert(result.message, {icon: 2});
                    }
                },
            });
            return false;
        });

    });

    function Submit() {
        document.getElementById('postButton').click();
        return callBackReturn;
    }
</script>
</html>